import React from 'react'
import {useSelector,useDispatch} from 'react-redux'
import {additionActionCreator} from '@/store/action/couterAction'
export default function Counter(props) {
  const num=useSelector((state)=>{
    return state.jishuqi.count
  })
  const dispatch=useDispatch()
  const increment=()=>{
    dispatch(additionActionCreator(props.n))
  }
  return (
    <div>
        <h1>计数器</h1>
        <h2>{num}</h2>
        <button onClick={increment}>+</button>
    </div>
  )
}
